/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package consys.social.memcached.dao.spymemcached;

import java.util.Collection;
import java.util.Map;
import net.spy.memcached.transcoders.Transcoder;

/**
 * Inteface for memcached operations
 *
 * @author Petr Kunc
 */
public interface Memcached {

    /**
     * Method returns the Object against the key or a null value if key value is
     * not available.
     * @param key value in the cache
     * @return the Object
     */
    Object get(String key);

    /**
     * Method returns the Object against the key or a null value if key value is
     * not available.
     * @param key value in the cache
     * @param tc transcoder that converts the object
     * @return the Object
     */
    Object get(String key, Transcoder tc);

    /**
     * Add an object to the cache if it does not exist.
     *
     * @param key value in the cache
     * @param the Object of key value pair
     * @param expiration the time in seconds value will be there in cache
     * @return boolean for success/failure to add in cache
     */
    boolean add(String key, Object value, int expiration);

    /**
     * Add an object to the cache if it does not exist.
     *
     * @param key value in the cache
     * @param the Object of key value pair
     * @param expiration the time in seconds value will be there in cache
     * @param tc transcoder that converts the object
     * @return boolean for success/failure to add in cache
     */
    boolean add(String key, Object value, int expiration, Transcoder tc);

    /**
     * Delete the given key from the cache.
     *
     * @param key value in the cache that needs to delete
     * @return boolean for success/failure to delete in cache
     */
    boolean delete(String key);

    /**
     * Set an object in the cache regardless of any existing value.
     *
     * @param key value in the cache
     * @param the Object of key value pair
     * @param cacheTimeMillis
     * @return boolean for success/failure to set in cache
     */
    boolean set(String key, Object value, int cacheTimeSeconds);

    /**
     * Set an object in the cache regardless of any existing value.
     *
     * @param key value in the cache
     * @param the Object of key value pair
     *
     * @return boolean for success/failure to set in cache
     */
    boolean set(String key, Object o);

    /**
     * Replace an object with the given value if there is already a value for
     * the given key.
     *
     * @param key value in the cache
     * @param the Object of key value pair
     * @param expiration the time in seconds value will be there in cache
     * @return boolean for success/failure to replace value in cache
     */
    boolean replace(String key, Object value, int expiration);

    /**
     * Replace an object with the given value if there is already a value for
     * the given key.
     *
     * @param key value in the cache
     * @param the Object of key value pair
     * @param expiration the time in seconds value will be there in cache
     * @param tc transcoder that converts the object
     * @return boolean for success/failure to replace value in cache
     */
    boolean replace(String key, Object value, int expiration, Transcoder tc);

    /**
     * Clear the memcached
     */
    void clear();

    /**
     * shutdown the client
     */
    void shutdown();

    <T> Map<String, T> getBulk(Collection<String> keys, Transcoder<T> tc);
    Map<String, Object> getBulk(Collection<String> keys);
}
